package service

import (
	"context"
	"errors"
	__ "order_srv/basic/orderproto"
	"order_srv/handler/dao"
)

func (s *Server) ReassignCreate(_ context.Context, in *__.ReassignCreateReq) (*__.ReassignCreateResp, error) {
	//参数校验
	if in.OrderId <= 0 {
		return nil, errors.New("订单id不能为空")
	}
	if in.UserId <= 0 {
		return nil, errors.New("用户不能为空")
	}
	if in.AssignDriver <= 0 {
		return nil, errors.New("新司机不能为空")
	}
	if in.Reason == "" {
		return nil, errors.New("改派原因不能为空")
	}

	reassign, err := dao.ReassignCreate(in)
	if err != nil {
		return nil, err
	}

	return &__.ReassignCreateResp{
		Id: reassign.Id,
	}, nil
}
